import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    redirect: "/index",
  },
  {
    path: "/index",
    name: "首页",
    component: () => import("@/views/home/index.vue"),
  },
  {
    path: "/my",
    name: "我的",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "@/views/my/MyPage.vue"),
  },
  {
    path: "/about",
    name: "关于",
    component: () => import("@/views/about/about.vue"),
  },
  {
    path: "/news",
    name: "新闻",
    component: () => import("@/views/news/news.vue"),
  },
  {
    path: "/profile",
    name: "资料",
    component: () => import("@/views/profile/profile.vue"),
  },
  {
    path: "/html",
    name: "HTML",
    redirect: "/flex",
    component: () => import("@/views/html/HtmlPage.vue"),
    children: [
      // html+css
      {
        path: "/flex",
        name: "flex",
        component: () => import("@/views/html/htmls/CssFlex.vue"),
      },
      {
        path: "/grid",
        name: "grid",
        component: () => import("@/views/html/htmls/CssGrid.vue"),
      },
      // js
      {
        path: "/promise",
        name: "promise",
        component: () => import("@/views/html/js/PromiSe.vue"),
      },
      {
        path: "/jsBasics",
        name: "jsBasics",
        component: () => import("@/views/html/js/JsBasics.vue"),
      },
      // vue
      {
        path: "/vueComps",
        name: "vueComps",
        component: () => import("@/views/html/vue/VueText.vue"),
      },
      {
        path: "/vueStudy",
        name: "vueStudy",
        component: () => import("@/views/html/vue/VueStudy.vue"),
      },
    ],
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;
